/*
 * Copyright 2012 The Eventio Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.eventio;

/**
 * Asynchronous request-reply resource signature. Implementors should ensure
 * that accessing this resource will not block the caller, and will execute the
 * associated {@link Reaction} in the {@link EventDispatcher} Thread when a
 * value is available.
 * <p>
 * To implement a resource on top of a synchronous system that blocks threads,
 * resource implementors can implement {@link Loadable} instead, and use a
 * {@link EventExecutor} to manage them.
 * 
 * @author mofleury
 * 
 * @param <INPUT>
 *            the resource input type
 * @param <OUTPUT>
 *            the resource output type
 * 
 * @see EventExecutor
 * @see Loadable
 * 
 */
public interface Resource<INPUT, OUTPUT> {

	/**
	 * requests a value from the resource, with the given input. This call
	 * registers the {@link Reaction} to be executed in the
	 * {@link EventDispatcher} thread when the return value is available.
	 * 
	 * @param input
	 * @param reaction
	 */
	void get(INPUT input, Reaction<Result<OUTPUT>> reaction);

}
